package com.ibeeking.found.msg.rest.controller.v1.feign;

import com.ibeeking.found.msg.rest.service.ISendSmsService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * @ClassName VerificationCodeController
 * @Description 验证码
 * @Author ibeeking
 * @Date 2020-12-08 15:33
 **/
@RestController
@RequestMapping("/msg/verificationCode/feign/v1")
public class VerificationCodeFeignController {

    @Resource
    private ISendSmsService sendSmsServiceImpl;

    @PostMapping(value = "/loginCheck/{key}/{mobile}", produces = "application/json; charset=UTF-8")
    public String queryVerificationCode(@PathVariable("key") @NotBlank(message = "验证码标识必填") String key, @PathVariable("mobile") @NotBlank(message = "手机号必填") String mobile) {
        return sendSmsServiceImpl.queryVerificationCode(key, mobile);
    }

    @PostMapping(value = "/clearVerificationCode/{key}/{mobile}")
    public Boolean clearVerificationCode(@PathVariable("key") @NotBlank(message = "验证码标识必填") String key, @PathVariable("mobile") @NotBlank(message = "手机号必填") String mobile) {
        return sendSmsServiceImpl.clearVerificationCode(key, mobile);
    }

    @PostMapping(value = "/checkVerificationCode/{key}/{mobile}/{code}")
    public Boolean checkVerificationCode(@PathVariable("key") @NotBlank(message = "验证码标识必填") String key, @PathVariable("mobile") @NotBlank(message = "手机号必填") String mobile, @PathVariable @NotBlank(message = "验证码") String code) {
        return sendSmsServiceImpl.checkVerificationCode(key, mobile, code);
    }
}
